
import re
from random import randint

def RandomString(options: str) -> str:

    length = 20
    chars = "a-zA-Z0-9 #!_-".split(" ")


    if not options:
        pass
    
    elif '-' in options.split(' ')[0]:
        chars = options.split(' ')
        
    elif len(options.split(' ')) >= 2:
        length = int(options.split(' ')[0])
        chars = options.split(' ')[1:]
        
    else:
        length = int(options.split(' ')[0])


    chars_list = re.findall(r'(.-.)', chars[0])
    
    out = ""
    
    for i in range(length):
        selected_chars = chars_list[ randint(0, len(chars_list)-1) ].split('-')
        choice = randint(0, len(chars)-1)
        
        match choice:
            case 0:
                out += chr( randint( ord(selected_chars[0]), ord(selected_chars[1]) ) )
            case 1:
                out += chars[1][ randint(0, len(chars[1])-1) ]

    
    return out

